import { createBrowserRouter } from "react-router-dom";

import App from "../App";
type Routertype = {
    path:string,
    element:JSX.Element,
    children?:{path:string,
        element:JSX.Element,}[]
}[]

const routes : Routertype=[
    {
        path:'/',
        element:<App/>,
        children:[
            {
                path:'/home',
                async lazy(){
                    const {default:Home}=await import('../pages/home/Index')
                    return{
                        element:<Home/>
                    }
                }
            },
            {
                path:'/todo',
                async lazy(){
                    const {default:Todo}=await import('../pages/todo/Index')
                    return{
                        element:<Todo/>
                    }
                },
                children:[
                    {
                        path:'/todo/data',
                        async lazy(){
                            const {default:Data}=await import('../pages/todo/data/Index')
                            return{
                                element:<Data/>
                            }
                        }
                    },
                    {
                        path:'/todo/data1',
                        async lazy(){
                            const {default:Data1}=await import('../pages/todo/data1/Index')
                            return{
                                element:<Data1/>
                            }
                        }
                    },
                ]
            },
            {
                path:'/my',
                async lazy(){
                    const {default:My}=await import('../pages/my/Index')
                    return{
                        element:<My/>
                    }
                }
            },
        ]
    }
]
const router=createBrowserRouter(routes)
export default router